package pool.errors;

import java.util.LinkedList;
import java.util.Queue;

import pool.test.client.Client;

public class ClientQueue {
	
	
	private Queue<Client> clients;
	private static ClientQueue instance = null;
	
	private ClientQueue(){
		clients = new LinkedList<Client>();
	}
	
	
	/** create instance */
	public synchronized static ClientQueue getInstance() {
		if (instance == null) {
			instance = new ClientQueue();
		}
		return instance;
	}
	
	
	public synchronized Client poll()   {
		Client c = clients.poll();
//		if(c!=null){
////			System.out.println("take from the pool..." + c.getClientName());
//		}
		return c;

	}
	
	public synchronized void add(Client c){
		clients.add(c);
	}
	
	public int getSize(){
		return clients.size();
	}
}
